﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AskiNowclass;
using System.Data;
using System.IO;
using System.Collections;
using System.Drawing;

public partial class writtenhelp : System.Web.UI.Page
{
    protected DataTable dt = new DataTable();
    protected DataTable dtcom = new DataTable();
    protected DataTable dtsubject = new DataTable();
    protected DataTable dtwork = new DataTable();
    protected DataTable dteducation = new DataTable();
    protected string userid = "";
    protected string realname = "";
    protected string descr = "";
    protected string eduinfo = "";
    protected string upic = "";
    protected string title = "";
    
    protected void Page_Load(object sender, EventArgs e)
    {

        userid = WebHelper.GetStringByFilter("userid");
        string sql = "select * from userinfo where userid=" + userid + "";
        dt = SqlHelper.Table(sql);
        if (dt.Rows.Count > 0)
        {

            realname = dt.Rows[0]["uname"].ToString();
            upic = dt.Rows[0]["upic"].ToString();
            title = dt.Rows[0]["title"].ToString();
            descr = dt.Rows[0]["descr"].ToString();
        }

        string sqlsubject = "select * from teachsubject where isdelete=0 and userid=" + userid + "";
        dtsubject = SqlHelper.Table(sqlsubject);

        string sqlcom = "select avg(star) as s,count(*) as c from Comment where ForClientid=" + userid + "";
        dtcom = SqlHelper.Table(sqlcom);

        string sqlwork = "select top 1 * from working where userid=" + userid + " order by startdate desc ";
        dtwork = SqlHelper.Table(sqlwork);
        if (dtwork.Rows.Count > 0)
        {

            descr = dtwork.Rows[0]["position"].ToString() + "," + dtwork.Rows[0]["company"].ToString();
        }

        // get the education information to fetch the most recent one
        string getEduSql =
            "SELECT * FROM education " +
            "WHERE userid=" + userid + " order by startdate desc";
        // we need to sort them by date later
        dteducation = SqlHelper.Table(getEduSql);

        if (dteducation.Rows.Count > 0)
        {
            string institute = dteducation.Rows[0]["institute"].ToString();
            string course = dteducation.Rows[0]["course"].ToString();
            string degree = dteducation.Rows[0]["degree"].ToString();
            eduinfo = institute + ", " + course + ", " + degree;

        }
    }
 
}